package cn.lixuan.constants;

import cn.lixuan.utils.PagedGridResult;
import cn.lixuan.utils.RedisOperator;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BaseInfoProperties {

    @Autowired
    public RedisOperator redis;

    public static final Integer COMMON_START_PAGE = 1;
    public static final Integer COMMON_PAGE_SIZE = 10;

    public static final String MOBILE_SMSCODE = "mobile_smscode_";
    public static final String REDIS_USER_TOKEN = "redis_user_token_";
    public static final String REDIS_USER_INFO = "redis_user_info_";

    // 我的关注总数
    public static final String REDIS_MY_FOLLOWS_COUNTS = "redis_my_follows_counts_";
    // 我的粉丝总数
    public static final String REDIS_MY_FANS_COUNTS = "redis_my_fans_counts_";

    // 我和博主的关联关系
    public static final String REDIS_FANS_AND_VLOGGER_RELATIONSHIP = "redis_fans_and_vlogger_relationship_";

    // 视频和发布者获赞数
    public static final String REDIS_VLOG_BE_LIKED_COUNTS = "redis_vlog_be_liked_counts_";
    public static final String REDIS_VLOGER_BE_LIKED_COUNTS = "redis_vloger_be_liked_counts_";

    // 用户是否喜欢/点赞视频，取代数据库的关联关系，1：喜欢，0：不喜欢(默认)
    public static final String REDIS_USER_LIKE_VLOG = "redis_user_like_vlog_";

    // 视频评论数量
    public static final String REDIS_VLOG_COMMENT_COUNTS = "redis_vlog_comment_counts_";

    // 视频单条评论被点赞的数量
    public static final String REDIS_VLOG_COMMENT_LIKED_COUNTS = "redis_vlog_comment_liked_counts_";

    // 用户是否点赞过该评论
    public static final String REDIS_USER_LIKE_COMMENT = "redis_user_like_comment_";

    public PagedGridResult setterPagedGrid(List<?> list,
                                           Integer page) {
        PageInfo<?> pageList = new PageInfo<>(list);
        PagedGridResult gridResult = new PagedGridResult();
        gridResult.setRows(list);
        gridResult.setPage(page);
        gridResult.setRecords(pageList.getTotal());
        gridResult.setTotal(pageList.getPages());
        return gridResult;
    }
}
